package com.lago.homework3;

import java.util.HashMap;

public class Exercise3 {
    public static void main(String[] args) {
        final String[] str = new String[]{"123", "456", "789", "123", "456"};

        HashMap<String, Integer> hm = new HashMap<>();
        for (String c:str){
            if(!hm.containsKey(c)){
                    hm.put(c,1);
            }
            else {
                hm.put(c,hm.get(c)+1);
            }
            //hm.put(c,!hm.containsKey(c)? 1 : hm.get(c) +1);
        }
        for (String c2 : hm.keySet()) {
            System.out.println(c2+": "+hm.get(c2));
        }
    }
}
